import request from '../utils/request'

export function login(data) {
    return request({
        url: '/uum-admin/api/v2/login/webLogin',
        // url: '/uum-auth/oauth/token',
        method: 'post',
        headers: {
            'Authorization': 'Basic d2ViLWNsaWVudDo2NTQzMjE=' // 客户端信息加密，明文：web-client:654321
        },
        data
    })
}

export function getGiteeUrl() {
    return request({
        url: '/uum-admin/api/v2/login/giteeUrl',
        method: 'get',
    })
}

export function giteeLogin(data) {
    return request({
        url: `/uum-admin/api/v2/login/giteeCallback?code=${data.code}&state=${data.state}`,
        method: 'post',
        headers: {
            'Authorization': 'Basic d2ViLWNsaWVudDo2NTQzMjE=' // 客户端信息加密，明文：web-client:654321
        }
    })
}

export function getInfo() {
    return request({
        url: '/uum-admin/api/v1/users/getDoorUserInfo',
        method: 'get'
    })
}

export function register(data) {
    return request({
        url: '/uum-admin/api/v2/users/register',
        method: 'post',
        data
    })
}

export function checkName(username) {
    return request({
        url: '/uum-admin/api/v2/users/checkName/' + username,
        method: 'get'
    })
}

export function reacquireEmail(username) {
    return request({
        url: '/uum-admin/api/v2/users/afreshActive/' + username,
        method: 'get'
    })
}

export function logout() {
    return request({
        url: '/uum-auth/oauth/logout',
        method: 'delete',
    })
}

export function activeAccount(code) {
    return request({
        url: '/uum-admin/api/v2/users/activeUser/' + code,
        method: 'get'
    })
}

export function visit() {
    return request({
        url: '/uum-admin/api/v2/users/index',
        method: 'get'
    })
}
